package com.example.spring.aware;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @Author: zhangrongqing
 * @Date: 2020/8/19 16:32
 */
@Component
public class SpringAwareTest implements ApplicationContextAware {

    ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public void get(){
        System.out.println(applicationContext.getBean("testController"));
    }
}
